Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requireTypeCheck option to guard-super-call #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anthony-unicare
Copy link

This fixes #134.

},

create(context): Rule.RuleListener {
let insideNonNativeElement = false;
let errNode = null;
const source = context.getSourceCode();
const options = context.options?.[0] ?? {};
const requireTypeCheck = options.requireTypeCheck ?? false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its probably better to just compare here, like options.requireTypeCheck === true

}
},
schema: [{
requireTypeCheck: {type: 'boolean'}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this object is meant to have a type i think, like:

    schema: [
      {
        type: 'object',
        properties: {
          requireTypeCheck: {type: 'boolean'}
        }
      }
    ]

@@ -100,7 +119,11 @@ const rule: Rule.RuleModule = {
if (isSuperHookExpression(node, hook)) {
errNode = node;
return true;
} else if (node.type === 'IfStatement' && !isSuperHook(node.test, hook)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i'd leave this as it is and just change isSuperHook to accept an extra requireTypeCheck parameter

inside isSuperHook, we could then:

if (requireTypeCheck) {
  return /* whatever a type checked super hook looks like */
}
return /* whatever a regular super hook looks like */

Copy link
Owner

@43081j 43081j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add some tests? 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Guard super call with typeof check
2 participants